# ECON 331  97/1
# ASSIGNMENT  #4
# 
# Question 1
# 
# a)
> restart;
# The demand function:
> Qd:= k*P^(-epsilon):
# Price elasticity of demand, 'ed':
> ed:= diff(Qd,P)*P/Qd;

                            ed := -epsilon

# The supply function:
> Qs:= c*(P-To):
# Price elasticity of supply, 'es':
> es:= diff(Qs,P)*P/Qs;

                                     P
                             es := ------
                                   P - To

# b)
> F:= Qd=Qs:
> dP_dTo:=simplify(implicitdiff(F,P,To)):
> Diff(P,To) = dP_dTo;
# 

                  d                  c P
                 --- P = ---------------------------
                 dTo        (-epsilon)
                         k P           epsilon + c P

# Note that 'P' is the equilibrium price here.
# c)
# The 'assume' command allows us to restrict the values of variables or
# parameters to specified intervals.  The following restrictions are
# appropriate for the market model:
> assume(k>0):
> assume(epsilon>0):
> assume(c>0):
> assume(P>0):
# These restrictions allow us to determine if 0 <   diff(P,To) < 1 by
# using the 'is' command:
> is(0<dP_dTo);

                                 true

> is(dP_dTo<1);

                                 true

# d)
# Since R = ToQs(P,To), where P is the equilibrium price and Qs is the
# equilibrium quantity, the total derivative of R with respect to To can
# be written as Qs + To*diff(Qs,To) .  Since Qs = c(P - To);  
# diff(Qs,To) = c*(diff(P,To) - 1).  This allows us to express the total
# derivative of R with respect to To as a relatively simple function of
# the equilibrium price and the parameters of the model:
> dR_dTo:=Qs+To*c*(dP_dTo-1);

dR_dTo :=

                         /              c~ P~                  \
    c~ (P~ - To) + To c~ |--------------------------------- - 1|
                         |     (-epsilon~)                     |
                         \k~ P~            epsilon~ + c~ P~    /

# The tildes ('~') attached to variables/parameters in the above
# expression is Maple's way of reminding us that we have restricted
# these values to certain intervals (part c).
# 
# QUESTION 2
# a)
> restart;
> C:=1600+40*Q+(2/3)*Q^(3/2):
> AC:=expand(C/Q);

                            1600             1/2
                      AC := ---- + 40 + 2/3 Q
                             Q

> MC:=diff(C,Q);

                                       1/2
                           MC := 40 + Q

# b)
> P:=100+512*Q^(-1/2):
> TR:=expand(P*Q);

                                           1/2
                        TR := 100 Q + 512 Q

> MR:=diff(TR,Q);

                                       256
                           MR := 100 + ----
                                        1/2
                                       Q

# c)
> Q:=solve(MC=MR,Q);

                              Q := 4096

> pi=evalf(TR-C);

                           pi = 102165.3333

# 
